﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace _17Net8AspNetCore_JWT.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class OrderController : ControllerBase
    {
        [Authorize]
        [HttpGet]
        public string GetOrder()
        {
            // 1、用户信息获取
            var userClaims = User.Claims;
            // 2、获取用户名称和密码
            string userName = userClaims.FirstOrDefault(c => c.Type == "name")?.Value;
            string password = userClaims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;

            return $"UserName:{userName} , password:{password}";
        }
    }
}
